package com.hn658.base.message.comet.filter;

import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.hn658.framework.cache.message.MessageCache;
import com.hn658.framework.logging.Logger;
import com.hn658.framework.logging.LoggerFactory;
import com.hn658.framework.shared.utils.JsonMapper;


/**
 * 拦截器基类
 * @author ztjie
 */
public abstract class AbstractBaseFilter implements Filter{
    /**
     * 日志记录器
     */
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    
    protected JsonMapper mapper = JsonMapper.nonEmptyMapper();
    
    protected ApplicationContext ac;
    
    protected MessageCache messageCache;
    
    @Override
	public void init(FilterConfig filterConfig) throws ServletException {
		ac = WebApplicationContextUtils.getWebApplicationContext(filterConfig
				.getServletContext());
		messageCache = ac.getBean(MessageCache.class);
	}
}
